package simple.demo.springintegration.demo.chapter5;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import simple.demo.springintegration.demo.chapter5.model.HelloPrototype;

public class ProtoApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/prototype-context.xml");
		context.start();
		
		ObjectFactory<HelloPrototype> factory = (ObjectFactory<HelloPrototype>)context.getBean("helloProtoFactory");
		for(int k=0; k<100; ++k)
		{
			HelloPrototype proto = (HelloPrototype)factory.getObject();
			System.out.printf("hello = %d, inner = %d\n", proto.getId(), proto.getProto().getId());
		}
	}

}
